<template>
    <!--    <div>载体</div>-->
    <div class="app-container">
        <el-row :gutter="10" class="mb8" ref="refbut">
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-download" @click="handleDC">导出</el-button>
            </el-col>
        </el-row>

        <el-table ref="table" v-loading="loading" :data="dataList" :height="tableHeight"
            @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="50" align="center" fixed="left" />
            <el-table-column label="是否运行中" prop="isRunning" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{ scope.row.isRunning == 1 ? "未完成" : "已完成" }}
                </template>
            </el-table-column>
            <el-table-column label="载体名称" prop="name" align="center" :show-overflow-tooltip="true">
              <template slot-scope="scope">
                    <span v-for="(i, idx) in dict.type.CARRIER_TYPE" :key="idx">
                            {{ scope.row.name == i.value ? i.label : '' }}
                        </span>
              </template>
            </el-table-column>
            <el-table-column label="是否通过" prop="" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{ scope.row.success == 1 ? "已通过" : "未通过" }}
                </template>
            </el-table-column>
            <el-table-column label="批次号" prop="batchId" align="center">

            </el-table-column>
            <el-table-column label="载体编号" prop="code" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button plain type="success" size="mini" @click="handleDetail(scope.row)">详情</el-button>
                    <el-button plain type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />
        <indexDetail v-if="isOpen" :isOpen="isOpen" :row="row" @closeDelDialog="closeDelDialog"></indexDetail>
    </div>
</template>
<script>
import estimateTableHeight from "@/mixins/estimateTableHeight";

import { yqCarriermanageDetailList,deleteByBatchId} from "@/api/cqbc/resourceManagement/yqCarriermanageDetail.js"

import indexDetail from "@/views/cqbc/resourceManagement/yqCarriermanageDetail/indexDetail.vue"
export default {
    mixins: [estimateTableHeight], // 混入方法
    archive_Dicts: ['CARRIER_TYPE'],
    components: { indexDetail },
    data() {
        return {
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            dataList: [],
            total: 0,
            queryParams: {
                pageNum: 1,
                pageSize: 10
            },
            isOpen: false,
            row:""
        }
    },
    created() {
        this.getList()
    },
    methods: {
        getList() {
            yqCarriermanageDetailList(this.queryParams).then(response => {
                this.dataList = response.rows
                this.total = response.total
                this.loading = false
            })
        },

        table_index(index) {
            return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.batchId)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        // 删除
        handleDelete(row) {
            const id = row.batchId || this.ids
            this.$modal.confirm('是否确认删除选中载体名称为"' + row.name + '"的数据项？').then(function () { }).then(() => {
                deleteByBatchId(id).then(res => {
                    if (res.code == "200") {
                        this.$modal.msgSuccess("删除成功");
                        this.getList();
                    }
                })
            }).catch(() => { });
        },

        //查看详情
        handleDetail(row){
            var that=this;
            console.log(row,"000000000000000000")
            this.row=row;
            this.isOpen=true;
        },

        //导出
      handleDC() {
        if (!this.multiple) {
          this.download("/cqbc/yqCarriermanageDetail/export?ids=" + this.ids, {}, `qingjia_${new Date().getTime()}.xlsx`);
        } else {
          this.$message({message: '请选择数据哦', type: 'warning'})
        }

      },

        //关闭详情
        closeDelDialog(){
            // var that=this;
            this.isOpen=false;
        }


    }
}
</script>

<style></style>
